layui.define(["jquery"], function (exports) {
    "use strict";

    let $ = layui.$

    let http

    let api = {
        /**
         * 配置http
         * @param {string} url 域名链接
         */
        http: function (url) {
            http = url
        },
        /**
         * get
         * @param {string} path 路径
         * @returns object
         */
        get: async function (path) {
            return await $.get(http + path).then(res => {
                return res
            })
        },
        /**
         * post
         * @param {string} path 路径
         * @param {object} data 数据
         * @returns object
         */
        post: async function (path, data) {
            return await $.post(http + path, data).then(res => {
                return res
            })
        }
    }

    exports('api', api); // 输出模块
});  